//
//  MineBMIView.m
//  Shine
//
//  Created by dllo on 16/3/14.
//  Copyright © 2016年 王斌. All rights reserved.
//

#import "MineBMIView.h"
#define WIDTHVIEW self.frame.size.width
#define HEIGHTVIEW self.frame.size.height
#define BGSVFSW self.backGroundSmallView.frame.size.width
#define BGSVFSH self.backGroundSmallView.frame.size.height
@implementation MineBMIView

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView{
    self.backGroundSmallView = [[UIView alloc] init];
    [self addSubview:self.backGroundSmallView];
    self.calculateBMILabel = [[UILabel alloc] init];
    [self.backGroundSmallView addSubview:self.calculateBMILabel];
    self.calculateBMIView = [[UIView alloc] init];
    [self.backGroundSmallView addSubview:self.calculateBMIView];
    self.heightNumberTextField = [[UITextField alloc] init];
    [self.backGroundSmallView addSubview:self.heightNumberTextField];
    self.cmLabel = [[UILabel alloc] init];
    [self.backGroundSmallView addSubview:self.cmLabel];
    self.heightNumberView = [[UIView alloc] init];
    [self.backGroundSmallView addSubview:self.heightNumberView];
    self.saveButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.backGroundSmallView addSubview:self.saveButton];
    self.xButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.backGroundSmallView addSubview:self.xButton];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    __weak typeof (self.backGroundSmallView) weakSelf = self.backGroundSmallView;
    [self.backGroundSmallView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(WIDTHVIEW, HEIGHTVIEW));
    }];
    self.backGroundSmallView.backgroundColor = [UIColor blackColor];
    self.backGroundSmallView.alpha = 0.8;
    
    [self.calculateBMILabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10);
        make.centerX.mas_equalTo(weakSelf.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(130, 20));
    }];
    self.calculateBMILabel.textColor = [UIColor whiteColor];
    self.calculateBMILabel.text = @"录入身高,计算BMI";
    self.calculateBMILabel.font = [UIFont systemFontOfSize:15];
    self.calculateBMILabel.textAlignment = YES;
    
    [self.calculateBMIView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(30);
        make.centerX.mas_equalTo(weakSelf.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(130, 2));
    }];
    self.calculateBMIView.backgroundColor = [UIColor lightGrayColor];
    
    [self.heightNumberTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(55);
        make.size.mas_equalTo(CGSizeMake(WIDTHVIEW-30, 40));
    }];
    self.heightNumberTextField.textColor = COLORYELLO;
    self.heightNumberTextField.font = [UIFont systemFontOfSize:40];
    self.heightNumberTextField.textAlignment = YES;
    self.heightNumberTextField.keyboardType = UIKeyboardTypeNumberPad;
    
    [self.cmLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(WIDTHVIEW-50);
        make.top.mas_equalTo(70);
        make.size.mas_equalTo(CGSizeMake(30, 20));
    }];
    self.cmLabel.textColor = [UIColor whiteColor];
    self.cmLabel.text = @"cm";
    
    [self.heightNumberView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(95);
        make.size.mas_equalTo(CGSizeMake(WIDTHVIEW-40, 1));
    }];
    self.heightNumberView.backgroundColor = [UIColor lightGrayColor];
    
    [self.xButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(WIDTHVIEW-30);
        make.top.mas_equalTo(5);
        make.size.mas_equalTo(CGSizeMake(30, 30));
    }];
    [self.xButton setImage:[UIImage imageNamed:@"quickInput_cancel@2x.png"] forState:UIControlStateNormal];
    
    [self.saveButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(HEIGHTVIEW-40);
        make.size.mas_equalTo(CGSizeMake(WIDTHVIEW-30, 30));
    }];
    [self.saveButton setTitle:@"保存" forState:UIControlStateNormal];
    [self.saveButton setTitleColor:COLORYELLO forState:UIControlStateNormal];
    self.saveButton.layer.borderWidth = 1;
    self.saveButton.layer.cornerRadius = 5;
    self.saveButton.layer.masksToBounds = YES;
    self.saveButton.layer.borderColor = COLORYELLO.CGColor;
}


@end
